<%--
  Created by IntelliJ IDEA.
  User: 12
  Date: 2023/3/2
  Time: 15:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<style>
    .table{
        text-align: center;
    }
</style>
<head>
    <title>购物车页面</title>
    <%--引入webjars--%>
    <script src="/webjars/jquery/3.6.0/jquery.min.js"></script>
    <link rel="stylesheet" href="/webjars/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="/webjars/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <h3>购物车信息</h3>
                </h3>
            </div>
            <table class="table">
                <tr>
                    <td>商品ID</td>
                    <td>商品名称</td>
                    <td>商品单价</td>
                    <td>挑选数量</td>
                    <td>小计(￥)</td>
                    <td>是否删除</td>
                </tr>
                <c:if test="${cart.maps.size() > 0}">
                <c:forEach var="map" items="${cart.maps}">
                <tr>
                    <td>${map.value.product.pid}</td>
                    <td>${map.value.product.pname}</td>
                    <td>${map.value.product.price}</td>
                    <td>${map.value.num}</td>
                    <td>${map.value.num * map.value.product.price}</td>
                    <td>
                        <a href="/cart?cmd=remove&pid=${map.value.product.pid}" class="btn btn-warning btn-sm">删除</a>
                    </td>
                </tr>
                </c:forEach>
                </c:if>
                <c:if test="${cart.maps.size() == 0}">
                    <tr>
                        <td colspan="6">
                            购物车已被清空！
                        </td>
                    </tr>
                </c:if>
            </table>
            <div class="panel-footer text-right">
                <a href="/index.jsp" class="btn btn-primary btn-sm">继续购物</a>
                <a href="/cart?cmd=clear" class="btn btn-danger btn-sm">清空购物车</a>
                总共消费（￥）：${cart.total}
            </div>
        </div>
    </div>
</body>
</html>
